package com.qf.controller;

import com.qf.pojo.Goods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@RestController
@RequestMapping("/goods")
@Slf4j
public class HelloController {

    @Value("${server.port}")
    private int port;

    @RequestMapping("/sayHello")
    public String sayHello(){
        return "Goods Hello!!! ---- " + port;
    }

    @GetMapping("/get")
    public String get(Integer id) {
//        System.out.println("id:" + id);
        System.out.println(1/id);
        return "goods -- id:" + id;
    }

    @GetMapping("/get2/{id}")
    public String get2(@PathVariable Integer id) {
        System.out.println("id:" + id);
        return "(2)goods --:" + Math.random();
    }


    @PostMapping("/add")
    public String add(@RequestBody Goods goods) {
        log.info("goods: {}" , goods);
        int i = 1/0;
        return "success";
    }
}
